
public class Solution {
    public TreeNode pre = null;
    public TreeNode head = null;
    public TreeNode Convert(TreeNode pRootOfTree) {

        if (pRootOfTree == null) {
            return null;
        }

        Convert(pRootOfTree.left);

        if(pre == null){
            head = pRootOfTree;
            pre = pRootOfTree;
        }else{
            pre.right = pRootOfTree;
            pRootOfTree.left = pre;
            pre = pRootOfTree;
        }

        Convert(pRootOfTree.right);
        return head;
    }
}